 /**
 * 逻辑、功能相关描述:
 *
 * @author yandawei 编写日期：2008-12-15
 */
package com.ce.pms.custservice.service.impl;

import com.ce.pms.base.service.impl.PmsBaseServiceImpl;
import com.ce.pms.custservice.model.DispatchFormDO;
import com.ce.pms.custservice.model.FeedbackRecord;
import com.ce.pms.custservice.service.IDispatchFormStateMachineService;
import com.ce.pms.exception.BusinessException;

/**
 * @author yandawei
 *
 */
public class DispatchFormStateMachineServiceImpl extends PmsBaseServiceImpl implements
		IDispatchFormStateMachineService {

	/* (non-Javadoc)
	 * @see com.ce.pms.custservice.model.IDispatchFormStateMachineService#decideStatuzWithAddFeedback(com.ce.pms.custservice.model.DispatchFormDO)
	 */
	public void decideStatuzWithAddFeedback(DispatchFormDO dispatchForm) {
		super.checkParameterIsNull(dispatchForm,"派工单不允许为空");
		if(DispatchFormDO.DISPATCH_STATUS_HANDLING_CODE.equals(dispatchForm.getStatuz())){
			for(FeedbackRecord feedBack : dispatchForm.getFeedbackRecordSet()){
				if(feedBack.getHasComplete().equals("1") && feedBack.getValidity().equals("1")){
					dispatchForm.setStatuzComplete();
					break;
				}
			}
		}else if(DispatchFormDO.DISPATCH_STATUS_NEW_CODE.equals(dispatchForm.getStatuz()) ||
				DispatchFormDO.DISPATCH_STATUS_COMPLETE_CODE.equals(dispatchForm.getStatuz())){
			throw new BusinessException("custservice:custservice_dform_cannot_addfeedback_exception",
									BusinessException.WARNING);
		}
	}


}
